package demo17;

import java.util.Scanner;

public class ThreadDemo2 {
    public static void main(String[] args) throws InterruptedException {
        Object lock1 = new Object();
        Object lock2 = new Object();

        Scanner s  = new Scanner(System.in);

        synchronized (lock1){
            synchronized (lock2){
                s.nextLine();   // lock1 & lock2

                s.wait(5_000);   // lock1


                s.nextLine();   // lock1 & lock2
            }
        }
    }
}
